package com.yong.automoguding.util;

import com.alibaba.fastjson.JSON;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;

public class HttpUtils {

    private static CloseableHttpClient httpClient;

    static {
        httpClient = HttpClientBuilder.create().build();
    }


    public static<T> T get(String url, Class<T> tClass) throws Exception {

        HttpGet get = new HttpGet(url);

        CloseableHttpResponse response = httpClient.execute(get);

        String string = EntityUtils.toString(response.getEntity());







        return JSON.parseObject(string, tClass);


    }


}
